package com.hanamaki.oop.demo02;

public class TravPerson {

    /**
     * 一个景区根据游人的年龄收取不同价格的门票。请编写游人类，当年龄大于等于18小于等于60时收费20元，否则就免费
     */
    String name;
    int age;
    String price;

    public TravPerson() {

    }

    public TravPerson(String name,int age) {
        this.name = name;
        if (age >= 18 && age <= 60) {
            this.age = age;
            this.price = "20";
        } else {
            this.price = "免费";
            this.age = age;
        }
    }

    @Override
    public String toString() {
        return "当前人的信息{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", price='" + price + '\'' +
                '}';
    }
}
